package com.content.service.impl;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import javax.annotation.Resource;

import org.apache.ibatis.session.SqlSession;
import org.mybatis.spring.support.SqlSessionDaoSupport;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.content.exception.UserExistException;
import com.content.mapper.UserMapper;
import com.content.mapperExtend.UserMapperExtend;
import com.content.mapperExtend.commentExtend;
import com.content.pojo.Article;
import com.content.pojo.ArticleClass;
import com.content.pojo.ArticleClassExample;
import com.content.pojo.BelongtoKey;
import com.content.pojo.CollectKey;
import com.content.pojo.Comment;
import com.content.pojo.Focus;
import com.content.pojo.User;
import com.content.service.UserService;


@Service("User")
@Transactional
public class UserServiceIml  implements UserService {

	@Resource
	public UserMapper userMapper;

	@Resource 
	public UserMapperExtend userMapperExtend;
	
	@Resource
	public commentExtend commentExtend;
	/*
	 * 这个是测试service**/
	@Override
	public List<User> findAllUser() {
		// TODO Auto-generated method stub
		List<User> findAllUser = userMapper.findAllUser();
		return findAllUser;
	}

	/*
	 * 注册[插入]**/
	public void addUser(User user){
		Date current=new Date();
        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 
        String c=sdf.format(current);
		user.setRegist_time(c);
		userMapperExtend.addUser(user);
		//return addUserString;
	}
	
	/*
	 * 登录**/
	@Override
	public List<User> getUser(User user) {
		// TODO Auto-generated method stub
		return userMapperExtend.getUser(user);
	}
	/*
	 * 更新登录时间**/
	@Override
	public void updateUserLoginTime(User user) {
		// TODO Auto-generated method stub
		Date current=new Date();
        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 
        String c=sdf.format(current);
		user.setLast_login_in(c);
		userMapperExtend.updateUserLoginTime(user);
	}

	@Override
	public Integer findUserName(String username) {
		// TODO Auto-generated method stub
		//userMapperExtend.findUserName(username);
		return userMapperExtend.findUserName(username);
	}

	@Override
	public Integer findUserById(String id) {
		// TODO Auto-generated method stub
		return userMapperExtend.findUserById(id);
	}

	@Override
	public User getUserInfo(String id) {
		// TODO Auto-generated method stub
		return userMapperExtend.getUserInfo(id);
	}

	@Override
	public void updateUserInfo(User user) {
		// TODO Auto-generated method stub
		userMapperExtend.updateUserInfo(user);
	}

	@Override
	public void modifyPassWord(User user) {
		// TODO Auto-generated method stub
		userMapperExtend.modifyPassWord(user);
	}

	@Override
	public List<ArticleClass> getUserClass(String id) {
		// TODO Auto-generated method stub
		return userMapperExtend.getUserClass(id);
	}

	@Override
	public void deleteUserClass(String id) {
		// TODO Auto-generated method stub
		userMapperExtend.deleteUserClass(id);
	}

	@Override
	public List<Article> getUserArticle(String id) {
		// TODO Auto-generated method stub
		return userMapperExtend.getUserArticle(id);
	}

	@Override
	public void deleteUserArticle(String id) {
		// TODO Auto-generated method stub
		userMapperExtend.deleteUserArticle(id);
	}

	@Override
	public void updateUserArticle(Article article) {
		// TODO Auto-generated method stub
		userMapperExtend.updateUserArticle(article);
	}

	
	@Override
	public void deleteComment(Comment comment) {
		// TODO Auto-generated method stub
		commentExtend.deleteComment(comment);
	}
	@Override
	public void insertComment(Comment comment) {
		// TODO Auto-generated method stub
		userMapperExtend.insertComment(comment);
	}

	@Override
	public List<Comment> showComment(String articleId) {
		// TODO Auto-generated method stub
		return commentExtend.showComment(articleId);
	}

	@Override
	public void addUserClass(ArticleClass articleClass) {
		// TODO Auto-generated method stub
		userMapperExtend.addUserClass(articleClass);
	}

	@Override
	public String getUserIdByArticle(String articleId) {
		// TODO Auto-generated method stub
		return userMapperExtend.getUserIdByArticle(articleId);
	}

	@Override
	public List<Article> searchArticleByWord(String title) {
		// TODO Auto-generated method stub
		return userMapperExtend.searchArticleByWord(title);
	}

	@Override
	public void updateUserAticleNum(User user) {
		// TODO Auto-generated method stub
		userMapperExtend.updateUserAticleNum(user);
	}

	@Override
	public void addArticleMapToClass(BelongtoKey belongtoKey) {
		// TODO Auto-generated method stub
		userMapperExtend.addArticleMapToClass(belongtoKey);
	}

	@Override
	public List<Article> getArticleInClass(String classId) {
		// TODO Auto-generated method stub
		return userMapperExtend.getArticleInClass(classId);
	}

	@Override
	public ArticleClassExample queryClassInfo(String classId) {
		// TODO Auto-generated method stub
		return userMapperExtend.queryClassInfo(classId);
	}

	@Override
	public void addCollection(CollectKey collectKey) {
		// TODO Auto-generated method stub
		userMapperExtend.addCollection(collectKey);
		
	}

	@Override
	public void addFocus(Focus focus) {
		// TODO Auto-generated method stub
		userMapperExtend.addFocus(focus);
	}

	@Override
	public void deleteCollection(CollectKey collectKey) {
		// TODO Auto-generated method stub
		userMapperExtend.deleteCollection(collectKey);
	}

	@Override
	public void deleteFocus(Focus focus) {
		// TODO Auto-generated method stub
		userMapperExtend.deleteFocus(focus);
	}

	@Override
	public List<Comment> getCommentsByArticle(String articleId) {
		// TODO Auto-generated method stub
		return userMapperExtend.getCommentsByArticle(articleId);
	}

	@Override
	public List<Focus> findFriend(String userId) {
		// TODO Auto-generated method stub
		return userMapperExtend.findFriend(userId);
	}

	@Override
	public List<Focus> showCommentInFocus(String userId) {
		// TODO Auto-generated method stub
		return userMapperExtend.showCommentInFocus(userId);
	}



	
}
